var vapp = new Vue({
	el: "#app",
	data: {
		name:'数据采集',
		url:'http://12.1.1.43:8001//kpnmrb/test/autonkhd.mvc',
		date:[]
	},
	mounted: function(){
		this.initData();
	},
	methods: {
		initData:function(){
			this.date.push(util.addDays(new Date(),-7));
			this.date.push(new Date());
		},
		save:function(){
			if(this.name.trim()==''){
				this.showError("任务名不能为空");
				return false;
			}
			var beginDate = this.date!=null?util.formatTime(this.date[0],'yyyy-MM-dd'):"";
	        var endDate = this.date!=null?util.formatTime(this.date[1],'yyyy-MM-dd'):"";
			var jsonStr = {
				"url":this.url,
				"req_data": "start_date="+beginDate+"&end_date="+endDate,
			};
			var reqData = {
				"jsonStr":JSON.stringify(jsonStr)
			};
			var data = tools.ajaxRequest("../schedule/scheduleSave", reqData);
			if(data.respCode=="0"){
				this.$message({
					  showClose: true,
			          message: '保存成功',
			          type: 'success'
			    });
				console.log(data);
			}else{
				this.showError(data.respDesc);
				return false;
			}

		},
		
		
		showError: function(info){
			var i = (info==undefined?"加载数据错误":info);
			this.$alert(i, '系统错误', {
		          confirmButtonText: '确定'
		    });	
		}
		
	},
	
});